package com.quxue.im.exception;


import com.quxue.im.vo.AjaxResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(LogicException.class)
    @ResponseBody
    public AjaxResult handleBusinessException(LogicException ex){
        return AjaxResult.error(ex.getMessage());
    }

    /**登录异常检查，如果没有登录，返回没有登录信息**/
    @ExceptionHandler(LoginException.class)
    @ResponseBody
    public AjaxResult handleLoginException(LoginException ex){
        return AjaxResult.error(401,ex.getMessage());
    }
}
